/**
 * $id$
 */
package org.ishequ.miduo;

import org.ishequ.miduo.R;
import org.ishequ.miduo.renren.ApiListActivity;
import org.ishequ.miduo.weibo.WeiboHomeActivity;
import weibo4android.Weibo;
import com.renren.api.connect.android.Renren;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public final class AppInvoker {
	
	private static Renren renren;
	private static Weibo weibo;
	
	/**
	 * Initialize the invoker. This method must be called before calling 'invoke'
	 * 
	 * @param renren
	 */
	public static void initRenren(Renren renren) {
		AppInvoker.renren = renren;
	}
	
	/**
	 * Initialize the invoker. This method must be called before calling 'invoke'
	 * 
	 * @param renren
	 */
	public static void initWeibo(Weibo weibo) {
		AppInvoker.weibo = weibo;
	}
	
	/**
	 * Call the app methods specified by its invoke name
	 * 
	 * @param activity The activity in which the method is called
	 * @param invokeName The name used to specify which demo method to be called
	 */
	public static void invoke(Activity activity, String invokeName) {
		if(invokeName.equals(activity.getString(R.string.app_weibo))) {
			Intent intent = new Intent(activity, WeiboHomeActivity.class);
			Bundle mBundle = new Bundle();  
	        mBundle.putSerializable("Weibo",weibo);  
	        intent.putExtras(mBundle);  
			activity.startActivity(intent);
		} else if(invokeName.equals(activity.getString(R.string.app_renren))) {
			Intent intent = new Intent(activity, ApiListActivity.class);
			intent.putExtra(Renren.RENREN_LABEL, renren);
			activity.startActivity(intent);
		} else if(invokeName.equals(activity.getString(R.string.app_qzone))) {
			
		} else if(invokeName.equals(activity.getString(R.string.app_t_qq))) {
			
		}
	}
	
}
